<template>
	<view>
		<view class="message-list">
			<view class="item">
				<view class="acea-row row-middle title">
					<view class="title-text line1">{{messageDetail.title || '通知消息'}}</view>
				</view>
				<view class="notice"> {{ messageDetail.content }}</view>
				<view class="notice" style="color: red;" @click="toCatch" v-if="messageDetail.infoId">立即查看</view>
				<view class="date">{{messageDetail.createTime}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		unusedList
	} from '@/api/message.js'
	export default {
		data() {
			return {
				messageDetail: {},
				infoType: {
					1: '发布',
					2: '访客',
					3: '匹配',
					4: '推荐',
					5: '收藏',
					6: '关注'
				},
			};
		},
		mounted() {
			this.getMessageRecord();
		},
		onLoad(option) {
			this.messageDetail = JSON.parse(option.detail)
		},
		methods: {
			// 获取站内信列表
			getMessageRecord() {
				unusedList().then(res => {
					// console.log(res)
					this.messageList = res.data.list;
				})
			},
			toCatch() {
				console.log("messageDetail", this.messageDetail)
				let url = '';
				if (this.messageDetail.infoType == 1 || this.messageDetail.type == 8) {
					url = '/pages/details/shopRent/shopRent?mind=1&id=' + this.messageDetail.infoId + '&storeCategory=' +
						this.messageDetail.storeCategory + '&st=' + this.messageDetail.status
				} else if (this.messageDetail.infoType == 2) { //二手
					url = '/pages/details/unused/unused?id=' + this.messageDetail.infoId
				} else if (this.messageDetail.infoType == 3) { //商家服务
					url = '/pages/details/merchantService/merchantService?id=' + this.messageDetail.infoId
				} else if (this.messageDetail.infoType == 4) { //供应链
					url = '/pages/details/supplyChain/supplyChain?id=' + this.messageDetail.infoId
				} else if (this.messageDetail.infoType == 5) { //招工
					url = '/pages/details/recruitWorkers/recruitWorkers?id=' + this.messageDetail.infoId
				} else if (this.messageDetail.infoType == 6) { //求租
					url = '/pages/details/askRent/askRent?mind=1&askrentId=' + this.messageDetail.infoId +
						'&storeCategory=' + this.messageDetail.storeCategory
				} else if (this.messageDetail.infoType == 7) {
					url = '/pages/details/askRent/askRent?mind=1&buystoreId=' + this.messageDetail.infoId +
						'&storeCategory=' + this.messageDetail.storeCategory
				} else if (this.messageDetail.infoType == 9) {
					url = '/pages/details/project/project?id=' + this.messageDetail.infoId
				} else if (this.messageDetail.infoType == 10) {
					url = '/pages/details/jobHunting/jobHunting?id=' + this.messageDetail.infoId
				} else if (this.messageDetail.infoType == 11) {
					url = '/pages/details/askSupply/askSupply?id=' + this.messageDetail.infoId
				}

				if (url) {
					uni.navigateTo({
						url
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.message-list {
		padding: 30rpx;

		.item {
			height: 95vh;
			margin-bottom: 30rpx;
			background: #ffffff;
			border-radius: 10rpx;
			padding: 30rpx;

			.title {
				width: 100%;
				font-size: 30rpx;
				font-weight: 400;
				color: rgba(0, 0, 0, 1);

				.new-doc {
					width: 12rpx;
					height: 12rpx;
					background: #EE212D;
					border-radius: 50%;
					margin-right: 12rpx;
				}

				.title-text {
					width: calc(100% - 40rpx);
				}
			}

			.notice {
				width: 100%;
				margin-top: 20rpx;
				font-size: 26rpx;
				font-weight: 400;
				line-height: 32rpx;
				color: rgba(128, 128, 128, 1);
			}

			.date {
				margin-top: 20rpx;
				font-size: 26rpx;
				font-weight: 400;
				color: rgba(166, 166, 166, 1);
			}
		}
	}
</style>